@extends('home.base')
@section('content')
  
  <link href="./wodeshoucang_files/myfavo.css" rel="stylesheet" type="text/css" /> 
  <link href="./wodeshoucang_files/reco_wrap.css" rel="stylesheet" type="text/css" /> 
 
  <link href="./wodeshoucang_files/win_login20150728.css" rel="stylesheet" type="text/css" /> 
  

  <iframe sandbox="allow-scripts" src="./wodeshoucang_files/cma.html" style="display: none;"></iframe> 
  <link href="./wodeshoucang_files/mydd_head.css" rel="stylesheet" type="text/css" /> 
  <link href="./wodeshoucang_files/mydd_public.css" rel="stylesheet" type="text/css" /> 
  <link href="./wodeshoucang_files/mydd_title.css" rel="stylesheet" type="text/css" /> 
  <link href="./wodeshoucang_files/mydd_leftnavi.css" rel="stylesheet" type="text/css" /> 
  <link href="./wodeshoucang_files/mydd_foot.css" rel="stylesheet" type="text/css" /> 
 
  
  <link href="./wodeshoucang_files/header_960_150803.css" rel="stylesheet" type="text/css" /> 
   
  

   
  
  
  <div class="mydnew_break">
   您现在的位置：
   <a href="http://www.dangdang.com/">当当</a> &gt; 
   <span><a href="http://myhome.dangdang.com/">我的当当</a></span> &gt; 
   <span>我的收藏</span> 
  </div> 
  <link href="./wodeshoucang_files/mydnew2.css" rel="stylesheet" type="text/css" /> 
  <link href="./wodeshoucang_files/dangdang.css" rel="stylesheet" type="text/css" /> 
  <link href="./wodeshoucang_files/mydnew.css" rel="stylesheet" type="text/css" /> 
  <a id="view_point" name="view_point"></a> 
  <div class="main_frame" style='height:700px;'> 
   <!--左栏--> 
   <div class="mydang_left"> 
    <div class="mydang_left_inner">  
     <ul style="padding:0px;" class="my_href" id="myfavoriteLink">
      <input type="hidden" id="rememberCustomerID" value="0" />
     </ul>
     <h3 class="mydang_left_title">个人中心<a class="slide_up" id="class640" href="javascript:void(click_a('class640','display640'))"></a></h3>
     <ul class="my_content" style="display:block;" id="display640">
      <li><a class="" target="_parent" href="http://orderb.dangdang.com/myallorders.aspx" name="myallorders">我的订单</a> </li>
      <li><a class="" target="_parent" href="http://customer.dangdang.com/profile/" name="profileleft">个人信息</a> </li>
      <li><a class="" target="_parent" href="http://safe.dangdang.com/" name="safe_center">安全中心</a> </li>
      <li><a class="" target="_parent" href="http://customer.dangdang.com/myaddress/myaddress.php" name="myaddress">收货地址</a> </li>
     </ul>
      <h3 class="mydang_left_title">我的收藏<a class="slide_up" id="class610" href="javascript:void(click_a('class610','display610'))"></a></h3>
     <ul class="my_content" style="display:block;" id="display610">
      <li><a href="javascript:;" class="on">商品收藏</a> </li>
     </ul>
    </div> 
   </div> 
   <link type="text/css" rel="stylesheet" href="./wodeshoucang_files/mydang.css" /> 
   <style type="text/css">
     /*设置弹出效果*/
.new_window{width:337px; border:solid 2px #447aa9; background-color:#f7fff8}
.wind_top{height:20px; padding:2px 2px 0 8px; background-color:#458bc9}
.wind_top .title_left{padding-top:2px; color:#fff; float:left}
.w_close{ float:right}



   </style> 
   <div id="tag_box1" style="display:none;position:absolute; z-index:20000;"></div> 
   <div id="callbackjs">
    
   </div> 
   
   <div class="main_right"> 
    <!--<div class="temp_navi">
                    <h2><b>我的收藏</b><span>(共有<b id="show_wish_count">1</b>件商品)</span></h2>
                </div>--> 
    <!-- 分类查找tab --> 
    <div class="shop_main_right"> 
     <div class="mydd_temp_title"> 
      <div class="mydd_temp_nav">
       <a href="javascript:;" class="now"><span>商品收藏</span></a>
      </div> 
     </div> 
     <div class="seek"> 
      <div class="mydd_temp_nav"> 
       <!-- <a id="category_search" href="javascript:;" class="now">按分类查找</a>  -->
       <a id="tag_search" href="javascript:;" style="display: ">通过标签查找</a>
      </div> 
     
     </div> 
     
     <div id="tag_search_div" class="tab_box" >
      <ul style="height: auto;display:block"> 
       <li><a href="javascript:;" id="alltags">全部</a></li>
       @if(!empty($tagg))
       @foreach($tagg as $key=>$value)
       <li><a href="javascript:;" class="tagslink" title="{{$key}}">{{$key}}({{$value}})</a></li>
       @endforeach
       @endif
       <li><a href="javascript:;" class="tagslink" title="notags_forNoRepeat">未使用标签</a></li>
      </ul>
     </div> 
    </div> 
    <div class="filter"> 
     <!-- <div class="tit">
      排序
     </div> 
     <ul class="sorting_box"> 
      <li id="sort_0" class="on"> 
       <div onclick="javascript:void(setCurLocation_new(0))" title="收藏时间从新到旧">
        时间
        <span class="icon "></span>
       </div> </li> 
      <li id="sort_2" class="" style="background-color: transparent;"> 
       <div onclick="javascript:void(setCurLocation_new(2))" title="商品价格从低到高">
        价格
        <span class="icon icon_t"></span>
       </div> </li> 
      <li id="sort_3" class="" style="background-color: transparent;"> 
       <div onclick="javascript:void(setCurLocation_new(3))" title="商品折扣从高到低">
        折扣
        <span class="icon "></span>
       </div> </li> 
      <li id="sort_6" class=""> 
       <div onclick="javascript:void(setCurLocation_new(6))" title="收藏人气从高到低">
        收藏人气
        <span class="icon "></span>
       </div> </li> 
     </ul>  -->
     <!-- <div class="display">  -->
      <!-- <div > -->
       <label class="alla" style="margin-left:10px;">收藏时间：</label>
       <select id="wish_time"><option value="1">近期收藏</option><option value="2">历史收藏</option></select>
      <!-- </div> --><!--  仅显示： 
      <label><input id="latest_reduce" type="checkbox" value="1" name="display" onclick="chooseOne(this)" />降价</label>
      <label><input id="latest_promo" type="checkbox" value="3" name="display" onclick="chooseOne(this)" />促销</label>
      <label><input id="no_product" type="checkbox" value="4" name="display" onclick="chooseOne(this)" />缺货</label>  -->
     <!-- </div>  -->
    </div> 
    <div class="op_box"> 
     <div class="paginating"> 
      <div class="pagepanel"> 
       <a href="javascript:void(0)" class="pagebtn disabled"><span>下一页</span></a>
       <a href="javascript:void(0)" class="current"><span>1</span></a>
       <a href="javascript:void(0)" class="pagebtn disabled"><span>上一页</span></a> 
      </div> 
      <div class="clear"></div> 
     </div> 
     <label class="all"><input type="checkbox"  id="Check_All_Up" class='bewithme' value='0' onclick="xuanzeAll(this.value)" />全选</label> 
     <a id="del_all_top" class="btn" href="piliangdel()">批量删除</a> 
     <a id="buy_all_top" class="btn" href="javascript:;">批量购买</a> 
     <!-- <a id="del_out_top" class="btn btn_none" href="javascript:;">删除全部下架商品</a>  -->
    </div> 
    <div class="op_box op_box2 myfavo_list"> 
     <span class="r1">商品信息</span>
     <span class="r2">金额</span>
     <span class="r3">库存 
      <select id="area_select"> 
       <option value="0">全国</option>
       <option value="111">北京</option>
       <option value="112">天津</option>
       <option value="113">河北</option>
       <option value="114">山西</option>
       <option value="115">内蒙古</option>
       <option value="121">辽宁</option>
       <option value="122">吉林</option>
       <option value="123">黑龙江</option>
       <option value="131">上海</option>
       <option value="132">江苏</option>
       <option value="133">浙江</option>
       <option value="134">安徽</option>
       <option value="135">福建</option>
       <option value="136">江西</option>
       <option value="137">山东</option>
       <option value="141">河南</option>
       <option value="142">湖北</option>
       <option value="143">湖南</option>
       <option value="144">广东</option>
       <option value="145">广西</option>
       <option value="146">海南</option>
       <option value="150">重庆</option>
       <option value="151">四川</option>
       <option value="152">贵州</option>
       <option value="153">云南</option>
       <option value="154">西藏</option>
       <option value="161">陕西</option>
       <option value="162">甘肃</option>
       <option value="163">青海</option>
       <option value="164">宁夏</option>
       <option value="165">新疆</option>
       <option value="171">台湾</option>
       <option value="172">香港</option>
       <option value="173">澳门</option>
     </select> </span>
     <script type="text/javascript">
        $('#area_select').change(function(){
            
            //模拟
            if($(this).val()=='143'){
                
                $("div[class='r3 center']").find('p').eq(1).html('缺货').css('color','red');
            }else{

                $("div[class='r3 center']").find('p').eq(1).html('现货').css('color','black');
            }
        });
     </script>
     <span class="r4">操作</span> 
    </div> 
    
    @foreach($list as $v)
    <ul class="myfavo_list clearfix"> 

     <li id="product_list_21015613" style="width: 780px; background-color: rgb(255, 255, 255);"> 
      <div class="r1"> 

       <input type="checkbox" class="chosen" name="CheckAll" id="{{$v->id}}"  value="" /> 
       <div class="things"> 
        <a title="{{$v->bookname}}" class="pic" href="{{url('home/detail')}}?id={{$v->pid}}&status={{$v->status}}" target="_blank">
         <img class="lazyload" alt=""  src="{{url('uploads/admin')}}/{{$v->pic1}}" width="70" />
        </a> 
       </div> 
       <div class="detail"> 
        <p><span class="icon icon_dang"></span><a class="title" href="{{url('home/detail')}}?id={{$v->pid}}&status={{$v->status}}" target="_blank">{{$v->bookname}}</a></p> 
        <p class="gray">收藏人气：{{$v->renqi}}人
          <span class="space">
             已有
            <a target="_blank" href="javascript:;">
              {{$v->pinglun}}
            </a>
            人评论
          </span>
        </p> 
        <p class="gray">收藏时间：{{date("Y-m-d",$v->time)}}</p> 
        <p class="tag_p" id="showtags">

          标签：
          @foreach($v->tag as $va) 
            @if(strlen($va)>12)
              <a href="javascript:;" class="tagslink" title="{{$va}} ">{{$va = iconv_substr($va,0,4)}} <span class='dot'>…</span></a>
            @else
              <a href="javascript:;" class="tagslink" title="{{$va}} ">{{$va}} </a>
            @endif
          @endforeach
          @if($v->tag[0]=='')
          <a name="edit" href="javascript:void(0)"  >
            添加
          </a>
          @else
          <a name="edit" href="javascript:void(0)"  >
            编辑
          </a> 
          @endif
          <!-- <input type="hidden" id="product_tagid_21015613" value="17933344,17933345" />  -->
        </p>

        <p class="tag_p" id="edittags3" style="display: none;">
          标签：
          <input id="producttags" type="text" class="text" /> 
          <a name="submit" href="javascript:void(0);" id="{{$v->bid}}">
            保存
          </a> 
          <a name="cancel" href="javascript:void(0);" >
           取消
          </a> 
        </p> 
        
        <p id="errorhint_21015613" class="wrong" style="display:none"></p> 
       </div> 
      </div> 
      <div class="r2 center"> 
       <p><span class="price">￥{{$v->nowprice}}&nbsp;({{$v->zhekou}}折)</span></p> 
       <p>{{$v->fuzhi}}<span class="price red">￥{{$v->chajia}}</span></p> 
      </div> 
      <div class="r3 center"> 
       <p>现货</p> 
      </div> 
      <div class="r4"> 
       <p>
          @if($v->history==1)
          <a id="go_cart" href="javascript:void(0);" dd_name="加入购物车">
            加入购物车
          </a>
          @else
          <a id="{{$v->id}}" href="javascript:void(0);" onclick="forback(this.id)">
            恢复收藏
          </a>
          @endif

        </p> 
        <br>
        <br>
       <p><a name="delete" href="javascript:;" id="{{$v->id}}">删除</a></p> 
      </div> </li> 
    </ul> 
    @endforeach
    <script type="text/javascript">
        function forback(ob)
        {   
            var id = ob;
            $.ajax({
              url:"{{url('home/forback')}}",
              type:"get",
              data:{id:id},
              dataType:'text',
              async:true,
              success:function(data){
                  window.location.href="{{url('home/mysc')}}?moren="+2;
              }
          });
        }
    </script>
    <div class="op_box op_box3 "> 
     <div class="paginating"> 
      <div class="pagepanel"> 
       <a href="javascript:void(0)" class="pagebtn disabled"><span>下一页</span></a>
       <a href="javascript:void(0)" class="current"><span>1</span></a>
       <a href="javascript:void(0)" class="pagebtn disabled"><span>上一页</span></a> 
      </div> 
      <div class="clear"></div> 
     </div> 
     <label class="all"><input type="checkbox"  id="Check_All_Down" class='bewithme' value='1' onclick="xuanzeAll(this.value)" />全选</label> 
     <a id="del_all_bottom" class="btn" href="javascript:;" onclick="piliangdel()">批量删除</a> 
     <a id="buy_all_bottom" class="btn" href="javascript:;" onclick="javascript:;">批量购买</a> 
     <script type="text/javascript"> 
          function piliangdel(){
              var idstring = '';
              //获取所有的被选中的
              $('.chosen:checked').each(function(){
                  var id = $(this).attr('id');
                  idstring += id+',';
              });
              if(idstring.length>0){
                  idstring = idstring.substring(0,idstring.length-1);
              }
              window.location.href="{{url('home/alldel')}}?path="+idstring;
          }
     </script>
     <!-- <a id="del_out_bottom" class="btn btn_none" href="javascript:;">删除全部下架商品</a>  -->
    </div> 
    <!-- 个性化推荐 --> 
   <div class="clear"></div> 
  
  </div> 
  <script type="text/javascript">
      //点击编辑时
      $("a[name='edit']").click(function(){
          $(this).parent('p').hide(); //被点击的这个p标签关闭

          //清空span然后隐藏后面跟着的点
          $(this).parent('p').find("a[class='tagslink']").find('span').hide();

          //把title里的值赋给要修改时的显示的值，即从title里面取
          $(this).parent('p').find("a[class='tagslink']").each(function(){
            $(this).html($(this).attr('title'));
          });
          
          
          var s = $(this).parent('p').find("a[class='tagslink']").text();//获取标签值
          $(this).parent('p').next('p').find('input').val(s);//放到input里
          $(this).parent('p').next('p').show();//出现包含input的p标签
      });

      //点击取消时
      $("a[name='cancel']").click(function(){
          $(this).parent('p').hide();//自己的这个p标签隐藏

          $(this).parent('p').prev('p').find("a[class='tagslink']").each(function(){

              //如果字符串大于5，就截断            
              if($(this).html().length>5){
                  var zhi = $(this).html().substr(0,4);
                  $(this).html(zhi);
              }
          });
          
          //出现原来的'...'
          // var span = document.createElement('span');
          // var text = document.createTextNode('…');
          // span.appendChild(text);
          // $(this).parent('p').prev('p').find("a[class='tagslink']").appendChild('span');
          $(this).parent('p').prev('p').find("a[class='tagslink']").each(function(){

              var kks = $(this).parent('p').prev('p').find("a[class='tagslink']").html();
              $(this).parent('p').prev('p').find("a[class='tagslink']").html(kks+'<span>…</span>');
          });
          
          // alert(s);
          $(this).parent('p').prev('p').show();//出现原来的

          $('.wrong').hide();
      });

      //点击保存时，用ajax判断其是否超过了3个标签
      $("a[name='submit']").click(function(){
          var tags = $(this).prev('input').val();//前面的val值
          var bookid = $(this).attr('id');
          // alert(bookid);
          // window.location.href="{{url('home/addtags')}}?tag="+tags+"&bid="+bookid;
          $.ajax({
              url:"{{url('home/addtags')}}",
              type:"get",
              data:{tag:tags,bid:bookid},
              dataType:'text',
              async:true,
              success:function(data){
                  //标签不能超过3个
                  if(data=='more3'){

                      //出现超过提示 有必要落魄至此？？
                      $('#'+bookid).parent('p').next('p').html("标签不能超过3个!").show();
                  }else if(data=='eight'){

                      //字符不能超过8个
                      $('#'+bookid).parent('p').next('p').html("字符不能超过8个！！").show();
                  } 
                  else {
                      window.location.reload();
                      //显示添加标签成功
                     // $('#'+bookid).parent('p').hide(); //隐藏编辑的input
                     // var z = $('this').prev('input').val();//获取填入的值
                     // //然后
                     // $('#'+bookid).parent('p').prev('p').show();//显示 显示的p

                     // //关闭错误提示的
                     // $('.wrong').hide();
                  }
                  
              },
              error:function(){
                  alert('wrong');
              }
          });
      });
    


      //绑定所有的标签然后跳转筛选
      $('.tagslink').click(function(){

          //移除别的class但是给自己加上
          // $('.tagslink').removeClass('now');
          // $('#alltags').removeClass('now');
          // $(this).addClass('now');

          //定义传过去的值
          var name = $(this).attr('title');
          
          //走起
          var urlurl = window.location.search;
          if(urlurl=='?moren=2'){

              window.location.href="{{url('home/fortags')}}?name="+name+"&moren=2";
          }else{

            window.location.href="{{url('home/fortags')}}?name="+name;
          }
      });

      //如果选的标签是全部的话
      $('#alltags').click(function(){

        //清空所有的class=now但是给'全部'加上
        // $('.tagslink').removeClass('now');
        // $(this).addClass('now');

        //直接走home下mysc即进入刚进入时的页面 
        window.location.href="{{url('home/mysc')}}";
      });

      //进来的时候 所有的 now 重分配 ，然后，给选中的标签附上class=now属性
      //通过地址栏获得，然后跟html里面的对比。。。恩。
      // $('.tagslink').removeClass('now');
      // $('#alltags').removeClass('now');

      //用js获取地址栏,实现点哪亮哪
      var search = decodeURI(window.location.search);
      if(search.match(/moren/)!=null){

          //历史 收藏 点亮！！
          $('#wish_time option:last-child').attr('selected',true);
      }//唉，~~
      // var two = $('.tagslink').attr('title');
      // for(var i=0;i<two.length;i++){
      //     alert(two[i]);
      // }
      
      ///^[\u4e00-\u9fa5]+$/
      // alert(search+a);


      //删除 还没完呢！修改状态为00000000进入历史收藏的东东！
      $("a[name='delete']").click(function(){
          $(this).parentsUntil('ul').fadeOut('slow');
          var id = $(this).attr('id');
          
          $.ajax({
              url:"{{url('home/fordel')}}",
              type:"get",
              data:{id:id},
              dataType:'text',
              async:true,
              success:function(shuju){
                // alert(shuju);
              }
          });
      });

      //做历史收藏！！！
      $('#wish_time').change(function(){
          var moren = $(this).val();
          if(moren==1){
            window.location.href="{{url('home/mysc')}}";
          }else{

            window.location.href="{{url('home/mysc')}}?moren="+moren;
          }
      });

      //全选的js
      // var cks = $("input[type='checkbox']");
      // cks.toggle(
      //     function(){
      //       cks.removeClass('btn_none');
      //     },
      //     function(){
      //       cks.addClass('btn_none');
      //     }
      // );
      // $('.bewithme').live("click",function(){
      //     $('.bewithme').removeClass('bewithme').addClass('goOut');
      //     $("input[type='checkbox']").checked = true;
      // });
      // $('.goOut').live("click",function(){
      //     $('.goOut').removeClass('goOut').addClass('bewithme');
      //     $("input[type='checkbox']").checked = false;
      // });
      // function xuanzeAll(clas){
          // var cla = $(this).attr('class');
          // alert(cla);
      // }
      function xuanzeAll(id){
        // alert(id);
        var cks = $("input[type='checkbox']");
        if(id == 0){
            for(var i=1;i<cks.length;i++){
              // if(cks.get(0).checked){
              //     cks.get(i).checked = false;
              // }else{
              //     cks.get(i).checked = true;
              // }
              cks.get(i).checked = !cks.get(i).checked;
              $('.btn_none').removeClass('btn_none');
            }
        }else{
          for(var i=0;i<cks.length-1;i++){

              // if(cks.get(0).checked){
              //     cks.get(i).checked = false;
              // }else{
              //     cks.get(i).checked = true;
              // }
              cks.get(i).checked = !cks.get(i).checked;
            }
        }

        if(('.chosen').checked==false){
            $('.chosen').addClass('btn_none');
        }else{
            $('.btn_none').removeClass('btn_none');
        }

      }

      
          
      // $('.chosen').click(function(){
      //     $(this).attr('checked',null);
      // });
  </script>
  @endsection